var app = angular.module('menuApp', []);
app.controller('menuController', function($scope, $http) {
	$scope.menu;
	$scope.menuList;
	
	$scope.view=function(){
		$http.get('sys/menus/getAll/').success(function(response){
			$scope.menuList=response.data;
			$("#sysMenuPid").select2({
				 placeholder: "请选择上级菜单",
				 allowClear: true
			});
        });
		$scope.menu={};
	}
	
	$scope.view();
	
	$scope.refreshData=function(){
		$scope.view();
	}
	
	$scope.menuSave=function(){
	   if($("#myForm").valid()){
		   $http.post('sys/menus/add/', $scope.menu).success(function(){
               redirectUrl("manage/menu/","list.jsp");
           });
	   }
	}
	
	$scope.menuReset=function(){
		$scope.view();
	}
	
	$scope.menuCancle=function(){
		redirectUrl("manage/menu/","list.jsp");
	}
});